package com.weitao.marketserver.controller;

import com.weitao.marketserver.mapper.AdminsMap;
import com.weitao.marketserver.pojo.Admins;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 管理员模块控制器
 */
@RestController
@RequestMapping("/admins")
public class AdminsCon {
    @Autowired
    public AdminsMap map;

    //插入数据的测试
    @RequestMapping("/insert")
    public int insertDatas(){
        List<Admins> list=new ArrayList<>();
        for (int i=0;i<5;i++){
            Admins admins=new Admins();
            admins.setRoles("Admin");
            admins.setUsername("zhanlang"+i);
            admins.setPassword("123456");
            list.add(admins);
            map.insert(admins);
        }
        return 1;
    }
    @RequestMapping("/all")
    public List<Admins> getAll(){
        return map.selectList(null);
    }
}
